package net.runsystem.magiccloud;

import net.runsystem.magiccloud.adapter.OnFragmentClickListener;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;

import com.actionbarsherlock.app.SherlockFragmentActivity;

public class LoginActivity extends SherlockFragmentActivity implements
		OnFragmentClickListener {

	private Fragment mContent;
	FragmentTransaction transaction;
	public static int THEME = R.style.Theme_Sherlock;

	@Override
	protected void onCreate(Bundle arg0) {

		setTheme(LoginActivity.THEME);
		// TODO Auto-generated method stub
		super.onCreate(arg0);

		// set the Above View
		setContentView(R.layout.content_frame);
		mContent = new A02_Login();
		transaction = getSupportFragmentManager().beginTransaction();
		transaction.replace(R.id.content_frame, mContent);
		transaction.commit();
		getSupportActionBar().hide();

	}

	@Override
	public void onItemClick(int fragmentId, int viewId) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onSwitchFragment(int fragmentId, Bundle data) {

		// TODO Auto-generated method stub
		switch (fragmentId) {
		case A05_Pass.A05_FRAGMENT_CODE:
			mContent = new A05_Pass();
			switchFragment(mContent, data);
			break;
		case A02_Login.A02_FRAGMENT_CODE:
			mContent = new A02_Login();
			switchFragment(mContent, data);
			break;
		case A03_NewAccount.A03_FRAGMENT_CODE:
			mContent = new A03_NewAccount();
			switchFragment(mContent, data);
			break;
		case A04_Infor.A04_FRAGMENT_CODE:
			mContent = new A04_Infor();
			switchFragment(mContent, data);
			break;
		case A04_01_ID.A04_01_FRAGMENT_CODE:
			mContent = new A04_01_ID();
			switchFragment(mContent, data);
			break;
		case A04_01a_QRCode.A04_01A_FRAGMENT_CODE:
			mContent = new A04_01a_QRCode();
			switchFragment(mContent, data);
			break;
		case A04_02_Size.A0402_FRAGMENT_CODE:
			mContent = new A04_02_Size();
			switchFragment(mContent, data);
			break;
		case A04_03_Date.A0403_FRAGMENT_CODE:
			mContent = new A04_03_Date();
			switchFragment(mContent, data);
			break;
		default:
			break;
		}

	}

	public void switchFragment(Fragment content, Bundle data) {

		if (data != null) {
			content.setArguments(data);
		}
		transaction = getSupportFragmentManager().beginTransaction();
		transaction.replace(R.id.content_frame, content);
		transaction.commit();

	}
}
